function SOLUTION=Solver_Main(PP,StdVec,FileName)

%% Steady State
SS          =   SteadyState_Solver(PP);

%% Construct the Model Structure
MODEL       =   Setup_MODEL(PP,SS);

% Check the Steady State in Equation Blocks
Res_NK      =   Equ_NK(PP,SS,0);
Res_HH      =   Equ_HH(PP,SS,MODEL,0);

if max(abs([Res_NK;Res_HH]))<1e-5
    fprintf('Steady State is Correct!\n');
else
    error('Steaty State is not Correct, check it  ...');
end


%% Compute the Jacobian
EquJac      =   struct();
EquJac.NK   =   Equ_NK(PP,SS,1);
EquJac.HH   =   Equ_HH(PP,SS,MODEL,1,[],[],1);
fir_ord     =   JacAssemble(MODEL,EquJac);
%% IRF
tic;
[gx,hx,gxhx_ExitFlag,gxhx_Info]=gx_hx(fir_ord,1);
toc;
if gxhx_ExitFlag~=1
    warning('Perturbation Solution is problematic');
    return
else
    solution    =   struct('gx',gx,'hx',hx);
end
solution    =   struct('gx',gx,'hx',hx);

if nargin<2 || isempty(StdVec)
    StdVec      =   [1 1 1 -1 -1 1]'*0.01/4;
end
IRF         =   IRF_1order(MODEL,solution,StdVec,[],120);

SOLUTION        =   struct('PP',PP,'SS',SS,'MODEL',MODEL,'EquJac',EquJac,...
                           'fir_ord',fir_ord,'gxhx',solution,'IRF',IRF);
if nargin==3 && ~isempty(FileName)
    save([FileName,'.mat'],'PP','SS','MODEL','EquJac','fir_ord','solution','IRF');
end